package com.zbkj.crmeb.task.wechat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.xxl.job.core.handler.annotation.XxlJob;
import com.zbkj.crmeb.wechat.service.TemplateMessageService;

@Component
@Configuration //读取配置
public class AsyncWeChatProgramTempMessage {
    @Value("${server.wechat-api-stauts}")
    private Boolean weChartApiStauts;
    //日志
    private static final Logger logger = LoggerFactory.getLogger(AsyncWeChatProgramTempMessage.class);
    @Autowired
    private TemplateMessageService templateMessageService;

    //1分钟同步一次数据
    @XxlJob("asyncWeChatProgramTempMessage")
    public void init(){
    	if(!weChartApiStauts) {
    		return;
    	}
        try {
            templateMessageService.consumeProgram();
        }catch (Exception e){
            e.printStackTrace();
            logger.error("AsyncWeChatProgramTempMessage.task" + " | msg : " + e.getMessage());
        }

    }
}
